﻿using static PLCSharp.Views.MotionController.Axis;
using static PLCSharp.Views.MotionController.InterpolationGroup;

namespace PLCSharp.Views.MotionController
{
    public abstract class ControllerSDK
    {
        public abstract bool Init(ushort controllerNo, string ip);
        public abstract void Close();
        public abstract void GetDI();
        public abstract void GetDQ();
        public abstract void SetDQ(ushort port, ushort off_on);
        public int DI_Count { get; set; }
        public List<uint> DI { get; set; } = [];
        public int DQ_Count { get; set; }
        public List<uint> DQ { get; set; } = [];
        public abstract void Get_Axis_Status(ushort axisNo);

        public abstract void Stop(ushort axisNo);
        public abstract void Reset(ushort axisNo);
        public abstract short CreateORG(ushort axisNo, AxisParams axisParams);
        public abstract short Power(ushort axisNo, bool onoff);
        public abstract bool CheckORG(ushort axisNo);
        public abstract short Move(ushort axisNo, ushort mode, AxisParams axisParams);

        public abstract short MulticoorMove(List<Interpolation> interpolations, InterpolationGroupParams interpolationParams);
        public abstract short Save(ushort axisNo, AxisParams axisParams);

        public ushort ControllerNo { get; set; }

        public List<AxisState> AxisIOs { get; set; } = [];

    }

    public class AxisState
    {
        public bool PowerOn { get; set; }
        public bool ALM { get; set; }
        public bool ORG { get; set; }
        public bool LimitP { get; set; }
        public bool LimitN { get; set; }
        public bool Moving { get; set; }
        /// <summary>
        /// 指令位置反馈
        /// </summary>
        public double CommandPosition { get; set; }
        /// <summary>
        /// 编码器位置
        /// </summary>
        public double EncoderPosition { get; set; }
        /// <summary>
        /// 速度反馈
        /// </summary>
        public double Velocity { get; set; }
    }

}
